package com.tian.print.app;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

/**
 * Description:
 * <br>Author：tian
 * <br>Time: 2019/5/23 19:54
 */
public class BaseModel {

    private CompositeDisposable mCompositeDisposable;

    public BaseModel() {
        mCompositeDisposable = new CompositeDisposable();
    }

    /**
     * 取消请求
     */
    public void cancelRequest() {
        boolean isDisposed = mCompositeDisposable.isDisposed();
        if (!isDisposed) {
            mCompositeDisposable.dispose();
        }
        mCompositeDisposable.clear();
        mCompositeDisposable = null;
    }

    protected void addDisposable(Disposable disposable) {
        mCompositeDisposable.add(disposable);
    }
}
